package org.chnxi.datastructures.josephulist;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

public class CircleSingleLinkedListTest {

    public static void main(String[] args) {
        CircleSingleLinkedList<Person> list = new CircleSingleLinkedList<Person>();
        //Person p0 = new Person(0,"DDD" , "ddd");
        Person p1 = new Person(1,"AAA" , "aaa");
        Person p2 = new Person(2,"BBB" , "bbb");
        Person p3 = new Person(3,"CCC" , "ccc");
        Person p4 = new Person(4,"DDD" , "ddd");
        Person p5 = new Person(5,"DDD" , "ddd");
//        Person p6 = new Person(6,"DDD" , "ddd");
//        Person p7 = new Person(7,"DDD" , "ddd");
//        Person p8 = new Person(8,"DDD" , "ddd");
//        Person p9 = new Person(9,"DDD" , "ddd");
//        Person p10 = new Person(10,"DDD" , "ddd");
//        Person p11 = new Person(11,"DDD" , "ddd");

        System.out.println("向单向循环链表中增加数据");
//        list.add(p0);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p4);
        list.add(p5);
//        list.add(p6);
//        list.add(p7);
//        list.add(p8);
//        list.add(p9);
//        list.add(p10);
//        list.add(p11);

        System.out.println("输出单向循环链表中的数据");
        list.printList();
        System.out.println("约瑟夫出圈：");
        list.josephu(0,2,5);

    }

}

@Data
@AllArgsConstructor
@NoArgsConstructor
class Person {
    private Integer idx;
    private String name;
    private String nickName;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(idx, person.idx);
    }

    @Override
    public int hashCode() {
        return Objects.hash(idx);
    }
}
